home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_02 / 9n02030a < prev    next >
Text File  |  1990-12-11  |  862b  |  31 lines

  1.  
  2.  
  3. void
  4. QuickSort( int *List, int Begin, int End )
  5. {
  6.         int Value, Tmp, i, j;
  7.  
  8.         if( End > Begin )
  9.         {
  10.                 /* Divide the list in two */
  11.                 Value = List[End];
  12.                 i = Begin - 1;
  13.                 j = End;
  14.                 do {
  15.                         while( List[++i] < Value );
  16.                         while( List[--j] > Value );
  17.                         Tmp = List[i];
  18.                         List[i] = List[j];
  19.                         List[j] = Tmp;
  20.                 } while( j > i );
  21.                 List[j] = List[i];
  22.                 List[i] = List[End];
  23.                 List[End] = Tmp;
  24.                 /* Sort the first part */
  25.                 QuickSort( List, Begin, i - 1 );
  26.                 /* Sort the last part */
  27.                 QuickSort( List, i + 1, End );
  28.         }
  29. }
  30.  
  31.